GBML manual / Instances

ystart

Where y was when this instance was created - never changes afterward.

Syntax

ystart: real (read-only in practice)

Description

Where y was the instant this instance was created - set once, from instance_create's own position, and never touched again afterward no matter how far the instance travels.

Like y itself, it is a place in the room counted from the room's top-left corner, so it can be compared with y directly.

Useful as a fixed anchor: a patrol that should always return home, a projectile that should despawn once it has flown far enough from where it was fired.

Example

if (y > ystart + 200 || y < ystart - 200) {
    instance_destroy(self);
}

Destroys the bolt once y has moved more than 200 pixels away from ystart, its own fixed starting point - a simple, self-contained range check (there is no built-in distance function yet - see dist_to - so this checks one axis at a time rather than true straight-line distance).